package scjp.preparation.concurrency;

import java.util.concurrent.atomic.AtomicInteger;

public class AtomicVariableTest {
	
	private static Integer integer = new Integer(0);
	private static AtomicInteger atomicInteger = new AtomicInteger(0);
	
	
	static class IntegerIncrementer extends Thread{
		public void run() {
			System.out.println("Integer incrementer is: " + ++integer);
		}
	}
	
	static class AtomicIntegerIncrementer extends Thread{
		public void run() {
			System.out.println("Atomic incrementer is: " + atomicInteger.incrementAndGet());
		}
	}
	public static void main(String[] args) {
		
		for(int i = 0; i < 5; i++) {
			new IntegerIncrementer().start();
			new AtomicIntegerIncrementer().start();
		}

	}

}
